package com.bridgeQQ.client.view.message
{
	import com.bridgeQQ.client.core.message.IMessageDisplay;
	
	import flash.desktop.NotificationType;
	import flash.display.InteractiveObject;
	
	import mx.collections.ArrayCollection;
	import mx.messaging.messages.IMessage;
	
	import spark.components.Group;
	
	public class MsgDisplayPanel extends Group implements IMessageDisplay
	{
		
		private var _topic:String;
		
		private var _closable:Boolean;
		
		private var msgs:ArrayCollection = new ArrayCollection();
		
		public function MsgDisplayPanel()
		{
			super();
		}
		
		public function openDisplay():void
		{
			if(this.stage)
			{
				var focus:InteractiveObject = this.defaultFocus;
				this.stage.focus = focus ? focus : this;
			}
		}
		
		protected function get defaultFocus():InteractiveObject
		{
			return null;
		}
		
		public function receiveMsg(msg:IMessage, notify:Boolean=true):void
		{
			var result:Boolean = receiveMsgInternal(msg);
			if(result && notify && this.stage && this.stage.nativeWindow)
			{
				this.stage.nativeWindow.notifyUser(NotificationType.INFORMATIONAL);
			}
		}
		
		protected function receiveMsgInternal(msg:IMessage):Boolean
		{
			msgs.addItem(msg);
			return true;
		}
		
		public function get receivedMsgs():ArrayCollection
		{
			return msgs;
		}
		
		public function get hide():Boolean
		{
			return false;
		}
		
		public function set topic(value:String):void
		{
			_topic = value;
		}
		
		public function get topic():String
		{
			return _topic;
		}
		
		public function set closable(value:Boolean):void
		{
			_closable = value;
		}
		
		public function get closable():Boolean
		{
			return _closable;
		}
	}
}